﻿using System;
using System.Diagnostics;

namespace ExplorerReset
{
    internal class Program
    {
        static void Main()
        {
            kill();
            openandclose();
            Environment.Exit(0);
        }
        private static void openandclose()
        {
            //重新打开资源管理器
            Process ps = Process.Start("explorer.exe");
            if (!ps.HasExited)
            {
                //关闭窗口
                ps.Kill();
            }
        }
        private static void kill()
        {
            // 结束所有正在运行的资源管理器进程
            foreach (Process process in Process.GetProcessesByName("explorer"))
            {
                try
                {
                    process.Kill();
                    process.WaitForExit(); // 等待进程结束
                }
                catch (Exception)
                {

                }
            }
        }
    }
}
